package com.xhwy.service.impl;

import com.xhwy.entity.Carousel;
import com.xhwy.mapper.CarouselMapper;
import com.xhwy.service.CarouselService;
import com.xhwy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 查询优先级最高的4条轮播图
     *
     * @return
     */
    @Override
    public R getAllByPriority() {
        List<Carousel> list = carouselMapper.getAllByPriority(4);
        //jdk 1.8 stream切割集合
        //list.stream().limit(2).collect(Collectors.toList());
        return R.ok("查询成功", list);
    }
}
